package fi.iki.joker.mobilogger.img;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.LinkedList;

import org.xml.sax.SAXException;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import fi.iki.joker.mobilogger.R;
import fi.iki.joker.mobilogger.db.ImageRepoBean;
import fi.iki.joker.mobilogger.exception.CaptchaChallengeException;
import fi.iki.joker.mobilogger.exception.GoogleClientLoginException;
import fi.iki.joker.mobilogger.exception.PicasaWebException;
import fi.iki.joker.mobilogger.img.ImageRepositoryConstants.ImageRepositoryType;
import fi.iki.joker.mobilogger.util.AlertUtil;
import fi.iki.joker.mobilogger.util.GoogleClientLoginUtil;
import fi.iki.joker.mobilogger.util.PicasaWebUtil;
import fi.iki.joker.mobilogger.util.PicasaWebUtil.PicasaWebAlbumTO;

public class FlickrInterface implements ImageRepository,View.OnClickListener {
	
	private static final String TAG = "FlickrInterface";
	private static final String FLICKR_API_KEY = "2c10824c4ef21a8a3937318bb3befcec";
	private static final String MSG_KEY = "messageKey";
	private static final int MSG_CODE_PREPARING = 1;
	private static final int MSG_CODE_COMMUNICATING = 2;
	private static final int MSG_CODE_DONE = 3;
	private static final int MSG_CODE_EXTRACTING = 4;
	private Activity parentRef = null;
	private Spinner userAlbums = null; 
	private ProgressDialog fetchProgress = null;
	private int fetchStatus = -1;
	private int currentlySelectedAlbum = -1;
	
	
	
	public void drawConfigFields(Activity parent, TableLayout tl, 
			Context context, int startIdFrom, int populateFromID) {
		this.parentRef = parent; 
		// first row of the flickr configurator has the button which onClick()
		// triggers the fetch of albums over the web
		TableRow tr1 = new TableRow(context);
		// second table row has the label and a spinner which has the fetched albums 
		// the user has.
		TableRow tr2 = new TableRow(context);
    	tr1.setId(startIdFrom);
    	tr2.setId(startIdFrom+1);
		TextView a = new TextView(context);
		EditText b = new EditText(context);
		b.setOnClickListener(this);
		TableRow.LayoutParams lp = new TableRow.LayoutParams();
		a.setText("Name of the photoset:");
		tr1.addView(a, lp);
		tr1.addView(b,lp);
		tr2.addView(userAlbums,lp);
		tl.addView(tr1, new TableLayout.LayoutParams());
		tl.addView(tr2, new TableLayout.LayoutParams());
	}
	
	public String getAuthId(String userName, String password) {
		// TODO Auto-generated method stub
		return null;
	}

	public void onClick(View v) {
		return;
	}
	
	public String getInterfaceConfig() {
		// TODO Auto-generated method stub
		return null;
	}

	public ImageRepositoryType getRepositoryType() {
		// TODO Auto-generated method stub
		return null;
	}

	public boolean setInterfaceConfig(String config) {
		// TODO Auto-generated method stub
		return false;
	}

	public String publishImage(Activity parentRef, ImageRepoBean repository, Uri imageUri,
			String fileName) {
		// TODO Auto-generated method stub
		return null;
	}
	
	private void endFetch() {
		fetchProgress.dismiss();
	}
	
}
